package com.weifeiyang.aidlserverdemo;

import android.os.Message;
import android.widget.TextView;

/**
 * Created by weifeiyang on 2016/6/12 0012.
 */

public class ServiceManagerUtil {


    /**
     * 处理发送数据
     *
     * @param fromPosition 来源
     * @param mBinder binder
     */
    public static void dealWithData(int fromPosition, MySingleService.MyBinder mBinder) {

        if (fromPosition == ManagerProject.COUNT.getFromPosition()) {//计算
            mBinder.count();
        } else if (fromPosition == ManagerProject.PEOPLE.getFromPosition()) {//人
            mBinder.people();
        }
    }

    /**
     * 处理结果
     *
     * @param fromPosition 来源
     * @param callBack 回调
     * @param result 结果
     */
    public static void dealWithResult(int fromPosition, MySingleNotifyCallBackInterface callBack, String methodName, String result) {
        callBack.notifyMainUiThread(fromPosition, methodName, result);
    }


    /**
     * 处理接受message
     * @param msg
     * @param textView
     */
    public static void dealWithMessage(Message msg, TextView textView) {
        String methodName = msg.getData().getString("methodName");
        String stringMsg = msg.obj.toString();
        textView.setText(methodName + "=" + stringMsg);
    }
}
